
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        ArrayList<Book> list = new ArrayList<>();
        System.out.println("input several Book,in the end #");
        Scanner in = new Scanner(System.in);
        String s = "";
        int count = 0;
        while (true) {
            s = in.next();
            if (s.equals("#")) break;
            String a[] = s.split(",");
            Book b1 = new Book(a[0], Double.parseDouble(a[1]));
            list.add(b1);
        }
        System.out.println("input a new Book:");
        String book = in.next();
        String b[] = book.split(",");
        Book b2 = new Book(b[0], Double.parseDouble(b[1]));
        for (int i = 0; i < list.size(); i++) {
            if (b2.compareTo(list.get(i)) == 1) {
                System.out.printf("new book:<%s>as same books\n", b[0]);
                System.out.println(list.get(i).name + "," + list.get(i).price);
            } else {
                count += 1;
                continue;
            }
        }
        if (count == list.size()) {
            System.out.printf("new book:<%s>as same books\n", b[0]);
        }
    }
}

class Book implements Comparable {
    public String name;
    public double price;

    public Book(String name, double price) {
        this.name = name;
        this.price = price;
    }

    @Override
    public int compareTo(Object obj) {
        Book b = (Book) obj;
        if (b.price == this.price) {
            return 1;
        } else {
            return 0;
        }
    }
}